Skip to content

test: add unit tests for string path helpers in _plotly_utils.utils#5660

Closed
eeshsaxena wants to merge 1 commit into
plotly:mainfrom
eeshsaxena:test/string-utils
Closed

test: add unit tests for string path helpers in _plotly_utils.utils#5660
eeshsaxena wants to merge 1 commit into
plotly:mainfrom
eeshsaxena:test/string-utils

Conversation

@eeshsaxena

Copy link
Copy Markdown
Contributor

Description

_plotly_utils/utils.py has a family of small pure string helpers used to
build the "did you mean" error messages for invalid property paths - splitting
a path, computing character positions, marking them, and suggesting the
closest valid key. Several of them had no direct test coverage.

This adds tests/test_core/test_utils/test_string_utils.py covering:

  • split_multichar (split on any of several chars; empty char list is a
    no-op)
  • split_string_positions (first-character index of each split piece)
  • display_string_positions (single index, offset/length/char/trim
    options, and the all-indices form) - using the exact examples from the
    docstrings
  • chomp_empty_strings (basic, leading-empty, no-op, the documented special
    cases []/['']/['','']/['','','',''], and reverse)
  • levenshtein (known distances, zero, empty operand, symmetry)
  • find_closest_string (nearest by edit distance, with lexicographic
    tie-break)
  • _natural_sort_strings (numeric-aware ordering, and reverse)

No source changes.

Verification

pytest tests/test_core/test_utils/test_string_utils.py - 15 passed.
ruff check / ruff format clean.

@eeshsaxena eeshsaxena closed this Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant